<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>{$meta_title}-狂雨小说CMS</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="__ADMIN__/css/admin.css"></head>
<body>
  <div class="layui-card layui-card-open">
    <div class="layui-card-body">
      <form class="layui-form" lay-filter="category" action="{:url()}">
        <div class="layui-form-item">
          <label class="layui-form-label">上级栏目</label>
          <div class="layui-input-block">
            <input type="text" name="ptitle" class="layui-input" disabled="disabled" value="{$category['title']|default='无'}">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">标题</label>
          <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" class="layui-input" value="{$info.title|default=''}">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">类型</label>
          <div class="layui-input-inline">
            <select name="type" lay-filter="type">
              <option value="0" {eq name="info.type|default='0'" value="0"}selected="selected"{/eq}>小说</option>
              <option value="1" {eq name="info.type|default='0'" value="1"}selected="selected"{/eq}>文章</option>
              <option value="2" {eq name="info.type|default='0'" value="2"}selected="selected"{/eq}>独立模版</option>
              <option value="3" {eq name="info.type|default='0'" value="3"}selected="selected"{/eq}>外链</option>
            </select>
          </div>
          <label class="layui-form-label">排序</label>
          <div class="layui-input-inline">
            <input type="text" name="sort" lay-verify="number" class="layui-input" value="{$info.sort|default='0'}">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">SEO标题</label>
          <div class="layui-input-block">
            <input type="text" name="meta_title" class="layui-input" value="{$info.meta_title|default=''}">
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">SEO关键字</label>
          <div class="layui-input-block">
            <textarea name="meta_keywords" class="layui-textarea">{$info.meta_keywords|default=''}</textarea>
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">SEO描述</label>
          <div class="layui-input-block">
            <textarea name="meta_description" class="layui-textarea">{$info.meta_description|default=''}</textarea>
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">图标</label>
          <div class="layui-input-block">
            <div class="input-group">
              <input type="text" name="icon" style="width:408px;" class="layui-input" value="{$info.icon|default=''}">
              <button class="layui-btn" id="upload" type="button" title="上传图标">上传图标</button>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">栏目模版</label>
          <div class="layui-input-inline w300">
            <div class="input-group">
              <input type="text" name="template_index" style="width:208px;" lay-verify="required" class="layui-input" value="{$info.template_index|default='type.html'}">
              <button class="layui-btn" type="button" onclick="admin_show('选择模版','{:url('template/select_template',['input'=>'template_index'])}',600,400)" title="选择模版">选择模版</button>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">内容模版</label>
          <div class="layui-input-inline w300">
            <div class="input-group">
              <input type="text" name="template_detail" style="width:208px;" lay-verify="required" class="layui-input" value="{$info.template_detail|default='novel.html'}">
              <button class="layui-btn" type="button" onclick="admin_show('选择模版','{:url('template/select_template',['input'=>'template_detail'])}',600,400)" title="选择模版">选择模版</button>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">筛选模版</label>
          <div class="layui-input-inline w300">
            <div class="input-group">
              <input type="text" name="template_filter" style="width:208px;" lay-verify="required" class="layui-input" value="{$info.template_filter|default='lists.html'}">
              <button class="layui-btn" type="button" onclick="admin_show('选择模版','{:url('template/select_template',['input'=>'template_filter'])}',600,400)" title="选择模版">选择模版</button>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <label class="layui-form-label">外链地址</label>
          <div class="layui-input-block">
            <input type="text" name="link" class="layui-input" value="{$info.link|default=''}">
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-input-block">
            <input name="id" type="hidden" value="{$info.id|default=""}" />
            <input type="hidden" name="pid" value="{$pid}">
            <button class="layui-btn" lay-submit lay-filter="ajax" type="submit">提交</button>
          </div>
        </div>
      </form>
    </div>
  </div>
  <script type="text/javascript" src="__STATIC__/jquery/jquery.min.js"></script>
  <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js"></script>
  <script type="text/javascript" src="__ADMIN__/js/admin.js"></script>
  <script type="text/javascript">
    var index = parent.layer.getFrameIndex(window.name);
    category_type($('[name="type"]').val());
    layui.use(['form','layer','upload','jquery'], function(){
      var layer =layui.layer;
      var form = layui.form;
      var upload = layui.upload;
      form.on('select(type)', function(data){
        category_type(data.value);
      });
      var uploadInst = upload.render({
        elem: '#upload' //绑定元素
        ,url: '{:url('upload/pic')}' //上传接口
        ,data: {path:'category'}
        ,done: function(data){
          if(data.code){
            layer.msg(data.msg, {icon: 1,shade: 0.3,time: 2000},function(layero, index){
                $('[name="icon"]').val(data.data.path);
            });
          }else{
            layer.msg(data.msg, {icon: 0,shade: 0.3});
          }
        }
      });
    });
    function category_type(type){
      $('.layui-form-item').show();
      switch(type){
      case "2":
        $('[name="template_index"]').parents('.layui-form-item').hide();
        $('[name="template_filter"]').parents('.layui-form-item').hide();
        $('[name="link"]').parents('.layui-form-item').hide();
        parent.layer.style(index,{height:'664px'});
        parent.$('#layui-layer-iframe'+index).height('621px');
        break;
      case "3":
        $('[name="meta_title"]').parents('.layui-form-item').hide();
        $('[name="meta_keywords"]').parents('.layui-form-item').hide();
        $('[name="meta_description"]').parents('.layui-form-item').hide();
        $('[name="template_index"]').parents('.layui-form-item').hide();
        $('[name="template_detail"]').parents('.layui-form-item').hide();
        $('[name="template_filter"]').parents('.layui-form-item').hide();
        parent.layer.style(index,{height:'381px'});
        parent.$('#layui-layer-iframe'+index).height('338px');
        break;
      default:
        $('[name="link"]').parents('.layui-form-item').hide();
        parent.layer.style(index,{height:'772px'});
        parent.$('#layui-layer-iframe'+index).height('727px');
      }
    }
  </script>
</body>
</html>